package org.keyintegrity.webbeans.utils;

import org.apache.tapestry.AbstractComponent;
import org.apache.tapestry.IMarkupWriter;
import org.apache.tapestry.IRequestCycle;

public abstract class XmlElement extends AbstractComponent {

    public abstract String getElement(); 
    
    @Override
    protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle) {
        if (getElement() != null) {
            if (getBodyCount() == 0) {
                writer.beginEmpty(getElement());
            } else {
                writer.begin(getElement());
                renderBody(writer, cycle);
                writer.end(getElement());
            }
        } else {
            renderBody(writer, cycle);
        }
    }

}
